<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>中北大学员工信息管理系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            font-family: 'Segoe UI', sans-serif;
            line-height: 1.6;
            background-color: #f8f9fa;
        }
        .container {
            max-width: 1200px;
            margin: 30px auto;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            padding: 2rem;
        }
        .page-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 2rem;
        }
        .btn-primary {
            background-color: #2563eb;
            border: none;
        }
        .btn-primary:hover {
            background-color: #1d4ed8;
        }
        .btn-danger {
            background-color: #ef4444;
            border: none;
        }
        .btn-danger:hover {
            background-color: #dc2626;
        }
        .btn-warning {
            background-color: #f59e0b;
            border: none;
        }
        .btn-warning:hover {
            background-color: #d97706;
        }
        .table-responsive {
            overflow-x: auto;
        }
        .custom-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 1rem;
        }
        .custom-table th,
        .custom-table td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #e0e0e0;
        }
        .custom-table th {
            background-color: #f5f5f5;
            font-weight: 600;
            color: #333;
        }
        .custom-table tbody tr:hover {
            background-color: #f9f9f9;
        }
        .action-buttons {
            display: flex;
            gap: 8px;
        }
        .form-inline {
            display: inline-flex;
            gap: 4px;
        }
        .empty-data {
            text-align: center;
            padding: 2rem;
            color: #6b7280;
        }
    </style>
</head>
<body>
<div class="container">
    <div class="page-header">
        <h2 class="text-primary">中北大学23130421班员工信息管理-范振宇</h2>
        <a href="GetAllEmployeeServlet" class="btn btn-primary">
            <i class="bi bi-list-check"></i> 刷新员工列表
        </a>
    </div>

    <div class="table-responsive">
        <table class="custom-table">
            <thead>
            <tr>
                <th>员工编号</th>
                <th>员工姓名</th>
                <th>员工工资</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody th:if="${not #lists.isEmpty(employeelist)}">
            <tr th:each="employee:${employeelist}">
                <td th:text="${employee.employeeid}"></td>
                <td th:text="${employee.employeename}"></td>
                <td th:text="${#numbers.formatDecimal(employee.employeesalary, 1, 2)}">
                    <!-- 格式化工资为两位小数 -->
                </td>
                <td class="action-buttons">
                    <form class="form-inline" action="DeleteEmployeeServlet" method="post">
                        <input type="hidden" name="employeeid" th:value="${employee.employeeid}">
                        <button type="submit" class="btn btn-danger"
                                onclick="return confirm('确定要删除员工 ${employee.employeename} 吗？')">
                            <i class="bi bi-trash"></i> 删除
                        </button>
                    </form>

                    <form class="form-inline" action="EditEmployeeServlet" method="get">
                        <input type="hidden" name="employeeid" th:value="${employee.employeeid}">
                        <button type="submit" class="btn btn-warning">
                            <i class="bi bi-pencil-square"></i> 修改
                        </button>
                    </form>
                </td>
            </tr>
            </tbody>
            <tbody th:if="${#lists.isEmpty(employeelist)}">
            <tr class="empty-data">
                <td colspan="4">
                    <i class="bi bi-exclamation-circle" style="font-size: 24px; color: #6b7280;"></i>
                    <p class="mt-2">暂无员工数据，请先添加员工</p>
                </td>
            </tr>
            </tbody>
        </table>
    </div>

    <!-- 引入 Bootstrap 图标 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"></script>
</div>
</body>
</html>